package com.tiancheng.trade.settlement.bo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tiancheng.trade.settlement.vo.BasePage;
import com.tiancheng.trade.settlement.vo.settlement.admin.SSettleLettersDetailQueryVo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * 对账函-基础查询条件
 */
@Data
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
@EqualsAndHashCode(callSuper = true)
public class SSettleLettersDetailQueryBO extends BasePage {
    /**
     * 结算周期-开始
     */
    /**
     * 统计起始时间
     */
    @NotNull(message = "结算周期开始时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonProperty("settle_start")
    private LocalDateTime settleStart;
    /**
     * 结算周期-结束
     */
    @NotNull(message = "结算周期结束时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonProperty("settle_end")
    private LocalDateTime settleEnd;

    /**
     * 业务场景，0-全场景
     */
    @JsonProperty("order_source")
    private String orderSource;

    /**
     * 商户编码，0-全场景
     */
    @JsonProperty("merchant_code")
    private String merchantCode;

    /**
     * 商户编码，0-全场景
     */
    @JsonProperty("org_code")
    private String orgCode;

    /**
     * 对账函类型
     * @see com.tiancheng.trade.settlement.enums.LettersTypeEnum
     */
    @JsonProperty("letters_type")
    private Integer lettersType;

    @JsonProperty("revenue_type")
    private String  revenueType;

    /**
     * 分页开始位置
     */
    private long position;
    private Integer dataStatus;

    public static SSettleLettersDetailQueryBO build(SSettleLettersDetailQueryVo vo){
        SSettleLettersDetailQueryBO bo = new SSettleLettersDetailQueryBO();
        bo.setOrderSource(vo.getOrderSource());
        bo.setMerchantCode(vo.getMerchantCode());
        bo.setOrgCode(vo.getOrgCode());
        bo.setLettersType(vo.getLettersType());
        bo.setRevenueType(vo.getRevenueType());
        bo.setPosition(vo.getPosition());
        bo.setDataStatus(vo.getDataStatus());

        bo.setCurrentPage(vo.getCurrentPage());
        bo.setPageSize(vo.getPageSize());
        bo.setStart(vo.getStart());
        bo.setSettleStart(LocalDateTime.of(vo.getSettleStart(), LocalTime.of(0, 0, 0)));
        bo.setSettleEnd(LocalDateTime.of(vo.getSettleEnd(), LocalTime.of(23, 59, 59)));
        return bo;
    }
}
